package net.apexes.commons.lang;

import java.util.Base64;
import java.util.Objects;

/**
 * @author hedyn
 */
public class Base91Demo {

    public static void main(String[] args) {
        String key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCpPdPa8hqMVO6N" +
                "+ggdlFatfLeZQGn7WK/14MrVqdrfsbf2q7Nd2vQvstaMHrjHoA5xnLYNZ4giSjuu" +
                "PXSi1xLl9A2JsqYijmGl0YmNBTwBfVsuP5ZbxFfoO2iLe/WgVAIm7JzqOga9RMm6" +
                "O3jvpp6rAgMBAAECggEAZAyX7IxJY4JmEGqqV4o0/5SGGUP6I0uXojyEzHEAYlN2" +
                "gvgNXoIA9OEO4g1EMm7HZpz8HTzfHVrBwgXFXhvISkNvq8oR8A48MwPl/ngqqKe3" +
                "BvMOxdi+oy2cEGUsVK5xNNdinOuyESoRstHelJifF7pgSU2umLbGnPxxACuu8sm0" +
                "9i9Hf4lXWB2FZRIWgrPq1NwzjSUBv9fXT1/hg9iViQKBgQDX2LzsinJD68lPCztS" +
                "n68MAZOx4T1MxGaDb8rFhob8KudHXeYQu29jWiQFC4RFzzom7ImY3UVXmvdHv1D1" +
                "0S3cKJyTjrn+tUKS/L9Ov/Den5+KPPJbJjjJsu61oFIp4Nq6AR0QG/fj+5WSfVEN" +
                "otpvWi5rNz1x8YMZ3bQM4sHIA9RctG9VIY03AHWStj4fqnnAzDDii58RBSuP1xj8" +
                "ReJdnIssR/TNJ+xNc7ABO2SdDZu/riSmFPKEOjAbTlG7yh5IqfAADGHcqD8pGtUF" +
                "o1ZADjDsCtLlaxyDWWuGq/wsVCdj5p0YQlw+RLP/K096Az+xwslf6R8WiTcXiL41" +
                "lN/0vwBOB+VHmqjhAER0z5a4SMO1Y/KXT8uPiRjWC94xp9bTGRkiwAAvalQQAiF0" +
                "Aj8YY6j6zS9vE1zZa+3uzQO63MpzdZ8oQBm0fsQzaeIES/qv+xXsfc3s26ks1FPF" +
                "Pf2WJN39FNrKtGDPqapuwCRayAerEgOXVMsxHX9/FFD5ajg86jAT+/Lvs9Zhezof" +
                "GGcz2u8l7wKBgQDCtKKHhcPZfSKVCP60WdNERd+ShBDRbLQWc1VNQc0l442XXNeC" +
                "EiEQ0eCp+PDpPQkosq8b8zwvBQKBgQDIuZ1N6/X1QeMywOV3O0CIHKQMD6IqkBWE" +
                "MD0sBglLOHUGPybeSV1TzdehYqvG+otaDaaCM7DD4un+m65dZgIL5nhNuQKBgQCV" +
                "LbYmSl8DBxPXDZu88HF2d2rId/n7DhifgpfoBXF57HL7Z3WTNW6hEwdZomxoQRun" +
                "lI2GmMpypqwLp4QV6nVVdJaXDS+SS+skgyQFYIyiGns0OOi2TadN8R2JORPH6+m3" +
                "s1aLD+ne91iKlpZeI1qcMVFFx/dljfWsz9UcTlV30seCbvAK7kgadFyF8aXds+ND" +
                "a3RvO+OPnnrW3K0Ui1Rw7dLU3TAvXCJiLj9AjmfZht1Q15w32g4Lv4uFWLKyRnIa" +
                "z28wMo8mIDBKHdJsG1TeFVspIQwMaOv6XkWdOXKRSwKBgFpYVN1wMK7jRC9w1O9q" +
                "3EDN4tWAuMzLdxJVgLpwOmjcSzxKrY+HRHvSp/gX+uurdW+QTsFA8sEilA1ueWK1" +
                "h7oFksvghXzqvS0IOyzR9UMT8TY1TgwszpkTku9R3S+i2lpQm7CcMfNx3ar5FhCK" +
                "vonQLAK7wt1p3/XsXIfzwUeJ";
        byte[] bytes = Base64.getDecoder().decode(key);
        String base64Text = Base64.getEncoder().encodeToString(bytes);
        String base91Text = Base91.encode(bytes);

        System.out.println("bytes.length: " + bytes.length);
        System.out.println("Base64: " + base64Text.length() + " : " + Objects.equals(base64Text, key) + " : " + base64Text);
        System.out.println("Base91: " + base91Text.length() + " : " + Objects.equals(Base64.getEncoder().encodeToString(Base91.decode(base91Text)), key) + " : " + base91Text);
    }
}
